-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Highlight the header of the topmost Window
#3515
Conversation
* Added a theme color for selected window header. * Added a function to retrieve the LayerId of the focused window. * Implemented a simple demo of this function in the demo app where a message states if the Option window is focused (at the bottom of the Options window).
I fully support your plan :) |
There is a way to work around this! If you use this pattern: let where_to_put_header_background = ui.painter().add(Shape::Noop);
// paint the collapsible button and figure out size of window…
ui.painter().set(
where_to_put_header_background,
epaint::RectShape::filled(…),
); |
We should pick a nomenclature and stick with it. In the demo you use "focus", which is already used in the context of "keyboard focus" (press tab to move keyboard focus, which doesn't change what window is on top). I think "top" is the best word to use, as it is the most accurate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding yet another color, could we reuse an existing one, e.g. visuals.widgets.hovered.bg_fill
?
The visual style is usually more relaxing when there is a limited pallett of colors
Co-authored-by: Emil Ernerfeldt <[email protected]>
* Corrected wording (use "on_top" instead of "focus"). * put back the constraint demo (I don't understand why it disappeared, but the tree was not in sync).
04261e4
to
a2b15b2
Compare
# Conflicts: # crates/egui/src/memory.rs
Window
There is a bug. When switching between dark and light tones, the setting of window_highlight_topmost will be set to true again. |
Could you please add the exact steps or the code to reproduce the problem, as well as the expected output and what you get on your side? |
// Calculate roughly how much larger the window size is compared to the inner rect | ||
let title_bar_height = if with_title_bar { | ||
let style = ctx.style(); | ||
ctx.fonts(|f| title.font_height(f, &style)) + title_content_spacing * 2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why only your window is broken, and no other one on egui.rs
Maybe you can make a PR to fix it?
This PR replaces an old one with many problems (no collapse icon, the header background was not funny colored, ugly...). It fixes those problems.
It implements the highlight of the header to the focused window. And allows the rest of the application to know the selected window. It allows, for instance, to display multiple windows with images and some additional meta information about those images on the side panel of the main window. The side panel updates itself according to the selected image window.
A technical point:
The header color is applied with a transparency of 125 so the collapsible button becomes visible.
The reason is that the collapsible button is rendered before the rest of the header and before the header size is known.
We cannot draw the background before knowing this value, so rendering with transparency is a solution to see the collapsible button through the header background.
This PR has been sponsored by my company, which left me to do it during my work time.
This is part of an evil plan to convince them to switch to rust for new projects :)
You can turn this off with
Visuals.window_highlight_topmost